/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CustomRolePane.java
 *
 * Created on Jan 8, 2012, 3:22:02 PM
 */
package views.panes;

import controller.human.Role;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author darkdev
 */
public class CustomRolePane extends javax.swing.JPanel {

    /** Creates new form CustomRolePane */
    JPanel parent;
    public CustomRolePane(JPanel parent) {
        initComponents();
        for(Role r: Role.values()){
            TextRoleName.addItem(r.toString());
        }
        this.parent = parent; 
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        nrPlayersRoleLabel = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        nrPlayersRole = new javax.swing.JSpinner();
        deleteRole = new javax.swing.JButton();
        TextRoleName = new javax.swing.JComboBox();

        setMaximumSize(new java.awt.Dimension(1000, 55));
        setMinimumSize(new java.awt.Dimension(405, 35));
        setPreferredSize(new java.awt.Dimension(405, 45));

        nrPlayersRoleLabel.setText("Number of players:");

        jLabel3.setText("Role:");

        deleteRole.setText("X");
        deleteRole.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        deleteRole.setMaximumSize(new java.awt.Dimension(25, 30));
        deleteRole.setMinimumSize(new java.awt.Dimension(25, 30));
        deleteRole.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                deleteRoleMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addComponent(TextRoleName, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(43, 43, 43)
                .addComponent(nrPlayersRoleLabel)
                .addGap(12, 12, 12)
                .addComponent(nrPlayersRole, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(deleteRole, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nrPlayersRoleLabel)
                    .addComponent(nrPlayersRole, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(deleteRole, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TextRoleName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void deleteRoleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_deleteRoleMouseClicked
        // TODO add your handling code here:
     ((CustomGamePane)parent).deleteRole(this.getX(),this.getY());
    }//GEN-LAST:event_deleteRoleMouseClicked

    public String getRoleName()
    {
        return TextRoleName.getSelectedItem().toString();
    }
    
    public int getNoPlayers()
    {
        return (Integer)nrPlayersRole.getValue();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox TextRoleName;
    private javax.swing.JButton deleteRole;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JSpinner nrPlayersRole;
    private javax.swing.JLabel nrPlayersRoleLabel;
    // End of variables declaration//GEN-END:variables
}
